package cn.zero.controller;

import cn.zero.domain.AjaxResult;
import cn.zero.domain.Product;
import cn.zero.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/product")
public class ProductController {
    @Autowired
    private IProductService productService;

    @PostMapping("/add")
    public AjaxResult add(@RequestBody Product product){
        try {
            productService.add(product);
            return new AjaxResult(true,"添加成功");
        }catch (Exception e){
            e.printStackTrace();
            return new AjaxResult(false,"操作失败");
        }
    }

}
